package com.newtype.meeting.client.model;

import java.io.Serializable;
import java.util.List;

import javax.jdo.annotations.Extension;
import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import com.extjs.gxt.ui.client.data.BaseTreeModel;

/**
 * 会议类别实体类
 * @author 汪恭泽
 * Jun 10, 2011 5:12:01 PM
 */

@SuppressWarnings("serial")
@PersistenceCapable(identityType = IdentityType.APPLICATION, detachable = "true")
public class MeetingCategory extends BaseTreeModel implements Serializable {
	@PrimaryKey
	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	@Extension(vendorName = "datanucleus", key = "gae.encoded-pk", value = "true")
	private String id;
	@Persistent
	private String parentId;
	@Persistent
	private String categoryName;

	public MeetingCategory() {

	}

	public MeetingCategory(String id, String categoryName) {
		set("id", id);
		set("categoryName", categoryName);
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getParentId() {
		return parentId;
	}

	public void setParentId(String parentId) {
		this.parentId = parentId;
	}

	public String getCategoryName() {
		return categoryName;
	}

	public void setCategoryName(String categoryName) {
		this.categoryName = categoryName;
	}

	public void updateProperties() {
		set("id", getId());
		set("parentId", getParentId());
		set("categoryName", getCategoryName());
	}

	public void updateObject() {
		setParentId((String) get("parentId"));
		setCategoryName((String) get("categoryName"));
	}

	public void setCategoryChildren(List<MeetingCategory> allChildren) {
		for (int i = 0; i < allChildren.size(); i++) {
			add(allChildren.get(i));
		}
	}
}
